<%--
    Document   : Massa
    Created on : 14/12/2011, 19:08:23
    Author     : Usuario
--%>

<%@page import="javax.swing.JOptionPane"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="cmstyle.css">
        <title>Volume</title>
          <script type="text/javascript">
            var ttipo='b';
        </script>
    </head>
    <body>
            <ul class="navbar">
            <li><a href="javascript:window.history.go(-1)">Voltar</a>
            <li><a href="/conversorMedidas/"> Home Page </a>
            <li><a href="equipe.jsp">Quem somos?</a>
            <li><a href="volume.jsp">Volume</a>
            <li><a href="moeda.jsp">Moeda</a>
            <li><a href="Aceleracao.jsp">Aceleração </a>
            <li><a href="corrente.jsp">Corrente Eletrica </a>
            <li><a href="Potencia.jsp">Potência</a>
            <li><a href="ConverterPrincipal.jsp">Velocidade</a>
            </ul>

        <h1>Conversor de Massa </h1>

        <form name="Entrada" action="">
            <br><BR>
            Quero Converter: <input type="text" name="entrada" value="" />

            <select name="TipoDeMassa1">
                <option>Tonelada</option>
                <option>Kilonewton</option>
                <option>Quilograma</option>
                <option>Hectograma</option>
                <option>Grama</option>
                <option>Quilate</option>
                <option>Centigrama</option>
                <option>Miligrama</option>
                <option>libra</option>
                <option>onça</option>
                <option>libra troy</option>
                <option>onça troy</option>
              </select>
             <input type="submit" value="Converter" name="bot" /> 
        </form>
            <form name="Entrada" action="">
            <br><BR>

                <select name="TipoDeMassa2">
                <option>Tonelada</option>
                <option>Kilonewton</option>
                <option>Quilograma</option>
                <option>Hectograma</option>
                <option>Grama</option>
                <option>Quilate</option>
                <option>Centigrama</option>
                <option>Miligrama</option>
                <option>libra</option>
                <option>onça</option>
                <option>libra troy</option>
                <option>onça troy</option>
              </select>
              </form>


        <%  String nome;
         try {
                        if (request.getParameter("TipoDeMassa1") != null && request.getParameter("entrada") != null) {

                     Double numero = Double.parseDouble(request.getParameter("entrada"));

        %>



        <%


        String a = "";
        nome = request.getParameter("TipoDeMassa1");
        double fator = 0 , fator1 , fator2 , res ;
        if (nome.equals("Tonelada")) fator = 1000;
        if (nome.equals("Kilonewton")) fator = 101.93;
        if (nome.equals("Quilograma")) fator = 1;
        if (nome.equals("Hectograma")) fator = 0.1;
        if (nome.equals("Grama")) fator = 0.001;
        if (nome.equals("Quilate")) fator = 0.0002;
        if (nome.equals("Centigrama")) fator = 0.00001;
        if (nome.equals("Miligrama")) fator = 0.000001;
        if (nome.equals("libra")) fator = 0.4535924;
        if (nome.equals("onça")) fator = 0.02834954;
        if (nome.equals("libra troy")) fator = 0.373241;
        if (nome.equals("onça troy")) fator = 0.031103;
        fator1 = fator;

        nome = request.getParameter("TipoDeMassa2");
     if (nome.equals("Tonelada")) fator = 1000;
        if (nome.equals("Kilonewton")) fator = 101.93;
        if (nome.equals("Quilograma")) fator = 1;
        if (nome.equals("Hectograma")) fator = 0.1;
        if (nome.equals("Grama")) fator = 0.001;
        if (nome.equals("Quilate")) fator = 0.0002;
        if (nome.equals("Centigrama")) fator = 0.00001;
        if (nome.equals("Miligrama")) fator = 0.000001;
        if (nome.equals("libra")) fator = 0.4535924;
        if (nome.equals("onça")) fator = 0.02834954;
        if (nome.equals("libra troy")) fator = 0.373241;
        if (nome.equals("onça troy")) fator = 0.031103;
       fator2 = fator;



%>
<br><br><h2>O resultado é:<%res = numero * fator1 / fator2;%></h2>

 <%

              }
          } catch (Exception e) {%><br><br><h1>Verifique se o campo foi preenchido corretamente </h1><%                      }
        %>
   
      
    </body>
</html>
